package com.zhangyu.shadow.core.weixin;

import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseResp;

/**
 * @author zhangyu
 * @date 2017/12/4
 */

public abstract class BaseWXPayEntryActivity extends BaseWXActivity {

    private static final int WX_PAY_SUCCEED = 0;
    private static final int WX_PAY_FAIL = -1;
    private static final int WX_PAY_CANCEL = -2;

    public abstract void paySucceed();

    public abstract void payFailed();

    public abstract void payCancel();

    @Override
    public void onResp(BaseResp baseResp) {
        if(baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
            int errorCode = baseResp.errCode;
            switch (errorCode) {
                case WX_PAY_SUCCEED:
                    paySucceed();
                    break;
                case WX_PAY_FAIL:
                    payFailed();
                    break;
                case WX_PAY_CANCEL:
                    payCancel();
                    break;
            }
        }
    }
}
